#!/usr/bin/env python
# -*- encoding: utf-8 *-*
#
# Focalist - a passive time track tools
#
# Copyright (c) 2008 Osvaldo Santana Neto <osantana@gmail.com>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
# 
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

import gobject
import gtk

from pkg_resources import resource_filename
from gettext import gettext as _


class MainWindow(gtk.Window):
    def __init__(self):
        super (MainWindow, self).__init__ (gtk.WINDOW_TOPLEVEL)

        icon = resource_filename(__name__, 'focalist.svg')
        self.set_icon_from_file(icon)

        self.action_group = self._create_action_group()
        self.manager = self._create_ui_manager(self.action_group)

        vbox = gtk.VBox(False, 0)

        menu = self.manager.get_widget('/Menubar')
        vbox.pack_start(menu, False)
        toolbar = self.manager.get_widget('/Toolbar')
        vbox.pack_start(toolbar, False)

        # list
        scroll = gtk.ScrolledWindow()
        scroll.set_policy(gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC)

        treeview = gtk.TreeView()

        scroll.add(treeview)
        vbox.pack_start(scroll, True)
        # /list

        status_bar = gtk.Statusbar()
        status_bar.set_has_resize_grip(True)
        vbox.pack_start(status_bar, False)

        self.add(vbox)
        self.set_size_request(320, 200)


    def _create_action_group(self):
        actions = [
            ('File', None, _("_File")),
            ('Reset', gtk.STOCK_NEW, _("_Reset All"), None, _("Reset counters"), self.on_menu_reset),
            ('Export', gtk.STOCK_SAVE, _("_Export..."), None, _("Export data"), self.on_menu_export),
            ('Quit', gtk.STOCK_QUIT, _("_Quit"), None, _("Close application"), self.on_menu_quit),
            ('Edit', None, _("_Edit")),
            ('Preferences', gtk.STOCK_PREFERENCES, _("_Preferences..."), None, _("Configure application"), self.on_menu_settings),
            ('View', None, _("_View")),
            ('Start', gtk.STOCK_MEDIA_PLAY, _("_Start"), None, _("Start counters"), self.on_menu_start),
            ('Pause', gtk.STOCK_MEDIA_PAUSE, _("_Pause"), None, _("Pause counters"), self.on_menu_pause),
            ('Help', None, _("_Help")),
            ('About', gtk.STOCK_ABOUT, _("_About..."), None, _("Informations about this application"), self.on_menu_about),
        ]
        ag =  gtk.ActionGroup('Actions')
        ag.add_actions(actions)
        return ag

    def _create_ui_manager(self, action_group):
        menu = '''
            <ui>
             <menubar name="Menubar">
              <menu action="File">
               <menuitem action="Reset"/>
               <menuitem action="Export"/>
               <separator/>
               <menuitem action="Quit"/>
              </menu>

              <menu action="Edit">
               <menuitem action="Preferences"/>
              </menu>

              <menu action="View">
               <menuitem action="Start"/>
               <menuitem action="Pause"/>
              </menu>

              <menu action="Help">
               <menuitem action="About"/>
              </menu>
             </menubar>

             <toolbar action="Toolbar">
              <placeholder name="JustifyToolItems">
               <separator/>
               <toolitem action="Reset"/>
               <toolitem name="_Export" action="Export"/>
               <separator/>
               <toolitem name="Start" action="Start"/>
               <toolitem name="Pause" action="Pause"/>
              </placeholder>
             </toolbar>
            </ui>
        '''

        manager = gtk.UIManager()
        manager.insert_action_group(action_group, 0)
        manager.add_ui_from_string(menu)
        return manager

    def on_menu_reset(self, data):
        pass

    def on_menu_export(self, data):
        pass

    def on_menu_quit(self, data):
        gtk.main_quit()

    def on_menu_settings(self, data):
        pass

    def on_menu_about(self, data):
        pass

    def on_menu_start(self, data):
        pass

    def on_menu_pause(self, data):
        pass


gobject.type_register(MainWindow)

# vim:ts=4:tw=120:sm:et:si:ai
